<treetable-submenu></treetable-submenu>

<div class="content-section introduction">
    <div>
        <span class="feature-title">TreeTable - <span class="subitem">Sections</span></span>
        <span>TreeTable provides templates to customize the content of various sections such as caption and summary.</span>
    </div>
</div>

<div class="content-section implementation">
    <p-treeTable [value]="files" [columns]="cols">
        <ng-template pTemplate="caption">
            FileSystem
        </ng-template>
        <ng-template pTemplate="header" let-columns>
            <tr>
                <th *ngFor="let col of columns">
                    {{col.header}}
                </th>
            </tr>
        </ng-template>
        <ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
            <tr>
                <td *ngFor="let col of columns; let i = index">
                    <p-treeTableToggler [rowNode]="rowNode" *ngIf="i == 0"></p-treeTableToggler>
                    {{rowData[col.field]}}
                </td>
            </tr>            
        </ng-template>
        <ng-template pTemplate="footer" let-columns>
            <tr>
                <td *ngFor="let col of columns">
                    {{col.header}}
                </td>
            </tr>
        </ng-template>
        <ng-template pTemplate="summary">
            There are {{files?.length}} Root Folders
        </ng-template>
    </p-treeTable>
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="treetablesectionsdemo.ts">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/treetable/treetablesectionsdemo.ts" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class TreeTableSectionsDemo implements OnInit &123;

    files: TreeNode[];

    cols: any[];

    constructor(private nodeService: NodeService) &123; &125;

    ngOnInit() &123;
        this.nodeService.getFilesystem().then(files => this.files = files);

        this.cols = [
            &123; field: 'name', header: 'Name' &125;,
            &123; field: 'size', header: 'Size' &125;,
            &123; field: 'type', header: 'Type' &125;
        ];
    &125;
&125;
</code>
</pre>   
        </p-tabPanel>

        <p-tabPanel header="treetablesectionsdemo.html">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/treetable/treetablesectionsdemo.html" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-treeTable [value]="files" [columns]="cols"&gt;
    &lt;ng-template pTemplate="caption"&gt;
        FileSystem
    &lt;/ng-template&gt;
    &lt;ng-template pTemplate="header" let-columns&gt;
        &lt;tr&gt;
            &lt;th *ngFor="let col of columns"&gt;
                &123;&123;col.header&125;&125;
            &lt;/th&gt;
        &lt;/tr&gt;
    &lt;/ng-template&gt;
    &lt;ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns"&gt;
        &lt;tr&gt;
            &lt;td *ngFor="let col of columns; let i = index"&gt;
                &lt;p-treeTableToggler [rowNode]="rowNode" *ngIf="i == 0"&gt;&lt;/p-treeTableToggler&gt;
                &123;&123;rowData[col.field]&125;&125;
            &lt;/td&gt;
        &lt;/tr&gt;            
    &lt;/ng-template&gt;
    &lt;ng-template pTemplate="footer" let-columns&gt;
        &lt;tr&gt;
            &lt;td *ngFor="let col of columns"&gt;
                &123;&123;col.header&125;&125;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/ng-template&gt;
    &lt;ng-template pTemplate="summary"&gt;
        There are &123;&123;files?.length&125;&125; Root Folders
    &lt;/ng-template&gt;
&lt;/p-treeTable&gt;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>